<template>
  <div class="goodsList">
    <div class="goodsItem" v-for="(item,index) in list" :key="item.id" @click="$router.push('/invest/detail/'+item.id)">
      <img v-lazy="item.img2 ?? item.img" class="goodsImg">
      <img src="@/assets/img/newPeople.png" class="newPeopleImg" v-if="item.new_user == 1">
      <div class="gIBottom">
        <div class="gTitle">
        <div class="tititleft line1">{{ item.title }}</div>
        <div class="tititTip" :class="[item.person_num ? '':'tititTipHide']">限购{{item.person_num}}份</div>
        </div>
        <div class="gTDeatil">
          <div class="gtdItem">
            <div class="dtdTop">{{ item.type == 1 ? $t('index.dailyRate') : $t('index.rate') }}</div>
            <div class="dtdNum line1" style="color: #1DB336">{{ item.rate }}%</div>
          </div>
          <div class="gtdItem">
            <div class="dtdTop">周期</div>
            <div class="dtdNum line1" style="color: #0069FF">{{ item.day }}{{ item.type == 3 ? $t('index.hour') : $t('index.day') }}</div>
          </div>
          <div class="gtdItem">
            <div class="dtdTop">{{ $t('invest.income') }}</div>
            <div class="dtdNum line1" style="color: #0069FF">{{ common.currency_symbol_basic() }}{{ change(item) }}</div>
          </div>
        </div>
        <div class="gTLine">
          <div class="lineActive" :style="{width:reduceNum(item) + '%'}"></div>
        </div>
        <div class="gtBtn">
          <div class="gtbLeft">金额：</div>
          <div class="gtbMoney line1NoWebkit">{{ common.precision_basic(item.min) }}</div>
          <div class="moneySize">U</div>
          <div class="gtbEmpt"></div>
<!--          <div class="btn">购买</div>-->
        </div>
      </div>
    </div>
  </div>
</template>
<script>
	export default {
		name: "list",
		props: {
			list: {
				type: Array,
				default: ()=> []
			}
		},
    data(){
      return {

      }
    },
		methods: {
      reduceNum(item){
         if(item.invest_num2 > 0){
           return item.invest_num2/item.num*100
         }else {
           return item.invest_num/item.num*100
         }
      },
      change(item) {
        if (item.type == 1) {
          return this.common.precision_basic(item.min * item.rate * item.day / 100);
        } else {
          return this.common.precision_basic(item.min * item.rate / 100);
        }
      },
		},
	}
</script>
<style lang="less" scoped>
.goodsList{
  .goodsItem{
    width: 45vw;
    display: inline-block;
    margin-bottom: 10px;
    position: relative;
    .newPeopleImg{
      position: absolute;
      top: 0;
      left: 0;
      width: 46px;
      height: 46px;
    }
    .goodsImg{
      width: 45vw;
      height: 45vw;
      border-radius: 10px 10px 0 0 ;
      display: block;
      object-fit: cover;
    }
    .gIBottom{
      box-sizing: border-box;
      background: #ffffff;
      padding:17px 10px 10px;
      border-radius: 0 0 10px 10px;
      .gTitle{
        font-size: 14px;
        font-weight: bold;
        margin-bottom: 10px;
        display: flex;
        align-items: center;
        .tititleft{
          flex: 1;
        }
        .tititTip{
           padding:4px;
           background: #BFE0FF;
          font-size: 12px;
          color: #0069FF;
          border-radius: 8px;
          font-weight: 400;
        }
        .tititTipHide{
          visibility: hidden;
        }
      }
      .gTDeatil{
        display: flex;
        justify-content: space-between;
        .gtdItem{
          font-size: 14px;
          font-weight: bold;
          overflow: hidden;
          .dtdTop{
            color: #707070;
            margin-bottom: 2px;
            white-space: nowrap;
          }
          .dtdNum{}
        }
      }
      .gTLine{
        width: 100%;
        height: 4px;
        background: #DEEBFE;
        border-radius: 4px;
        margin: 5px 0 8px;
        overflow: hidden;
        position: relative;
        .lineActive{
          position: absolute;
          top: 0;
          bottom: 0;
          left: 0;
          background: linear-gradient(90deg, #0038FF 0%, #0189FF 100%);
          border-radius: 4px;
        }
      }
      .gtBtn{
        display: flex;
        align-items: center;
        font-size: 14px;
        .gtbLeft{
          color: #707070;
          white-space: nowrap;
        }
        .gtbMoney{
          color: #FF0000;
          font-size: 14px;
          font-weight: bold;
        }
        .moneySize{
          color: #FF0000;
          font-size: 12px;
          padding-top: 2px;
          font-weight: bold;
        }
        .gtbEmpt{
          flex: 1;
        }
        .btn{
          padding: 4px 6px;
          background: linear-gradient(0deg, #018DFF 0%, #0038FF 100%);
          color: #ffffff;
          border-radius: 4px;
          white-space: nowrap;
          margin-left: 5px;
        }
      }
    }
  }
  .goodsItem:nth-child(2n + 1){
    margin-right: 4vw;
  }
}
</style>
